<?php

namespace app\common\model;

use think\Model;

class WeChat extends Model
{
    // 表名
    protected $name = 'wx_user';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    
    // 追加属性
    protected $append = [

    ];




    /**
     * 插入微信会员信息
     */
    public function ToWxUser($param){
        $param['createtime'] = time();
        //默认送金币100
        $param['currency'] = 100;
        $param['nickname'] = bin2hex($param['nickname']);
        $this->data = $param;
        if($res = $this
            ->where('openid',$param['openid'])
            ->find()){
        }else{
            $res = $this->allowField(true)->save();
        }
        return $res;
    }





}
